<!doctype html>
<html>
<head>
<template source='TPL:admin.common.head' />
</head>
<body>
<div class="wrap J_check_wrap">
	
		<div class="nav">
			<ul class="cc">
				<li class="current"><a href="{@url:/tag/manage/run}">话题管理</a></li>
				<li><a href="{@url:/tag/manage/category}">话题分类</a></li>
			</ul>
		</div>
		<div class="h_a">功能说明</div>
		<div class="prompt_text">
			话题，也叫标签，通过给帖子设置标签，可以将不同版块的帖子汇聚在一起，形成另一种维度的内容聚合。
		</div> 
		<div class="h_a">搜索</div>
		<div class="search_type cc mb10">
			<form action="{@url:/tag/manage/run}" method="post">
			<input type="hidden" name="{$moduleKey}" value="tag" />
			<input type="hidden" name="{$controllerKey}" value="manage" />
			<div class="ul_wrap">
				<ul class="cc">
					<li>
						<label>话题名称：</label><input type="text" class="input length_3" name="keyword" value="{$keyword}">
					</li>
					<li>
						<label>热门话题：</label>
							<select name="ifhot" class="select_3">
								<option value="-1"<!--# if($ifhot=='-1'){ #--> selected<!--# } #-->>不限</option>
								<option value="1"<!--# if($ifhot=='1'){ #-->  selected<!--# } #-->>热门</option>
								<option value="0"<!--# if(is_numeric($ifhot) && $ifhot=='0'){ #-->  selected<!--# } #-->>不热门</option>
							</select>
					</li>
					<li>
						<label>话题分类：</label>
						<select name="categoryId" class="select_3">
							<option value="0">不限</option>
							<!--# foreach($categories as $v){ #-->
							<option value="{$v['category_id']}"<!--# if($v['category_id']==$categoryId){ #--> selected<!--# } #-->>{$v['category_name']}</option>
							<!--# } #-->
						</select>
					</li>
					<li>
						<label>关注数：</label><input class="input length_1 mr10" type="number" name="minAttention" value="{$minAttention}"><span class="mr10">至</span><input class="input length_1" type="text" name="maxAttention" value="{$maxAttention}">
					</li>
					<li>
						<label>内容数：</label><input class="input length_1 mr10" type="number" name="minContent" value="{$minContent}"><span class="mr10">至</span><input class="input length_1" type="text" name="maxContent" value="{$maxContent}">
					</li>
				</ul>
			</div>
			<div class="btn_side">
			<button class="btn" type="submit">搜索</button>
			</div>
			</form>
		</div>
		<div class="mb10"><a title="添加话题" href="{@url:/tag/manage/add}" class="btn J_dialog"><span class="add"></span>添加话题</a></div>
		<!--# if ($tags) { #-->
		<form method="post" action="#" id="J_tag_form" class="J_ajaxForm">
		<div class="table_list">
			<table width="100%">
				<colgroup>
					<col width="65">
					<col width="70">
					<col width="250">
					<col>
					<col>
					<col width="120">
				</colgroup>
				<thead>
					<tr>
						<td><label><input class="J_check_all" data-checklist="J_check_x" data-direction="x" type="checkbox">全选</label></td>
						<td>话题logo</td>
						<td>名称/描述</td>
						<td>内容数/被关注数</td>
						<td>话题分类</td>
						<td>关联话题</td>
						<td>允许热门</td>
						<td>操作</td>
					</tr>
				</thead>
				<tbody id="J_tag_list">
				<!--# foreach($tags as $v){
					$relatedTopics = $v['joinTag'];
					$realtedTopicsHtml = array();
					if ($relatedTopics) {
						foreach ($relatedTopics as $v2){
							$realtedTopicsHtml[] = $v2['tag_name'];
						}
					}
				#-->
				<tr>
					<td><input class="J_check" name="tag_id[]" value="{$v['tag_id']}" data-name="{$v['tag_name']}" data-tid="{$v['tag_id']}" data-xid="J_check_x" data-yid="J_check_y" type="checkbox"></td>
					<td><img src="{@Pw::getPath($v['tag_logo'])}" width="50" height="50" class="fl" onerror="this.onerror=null;this.src='<?php echo Wekit::url()->themes; ?>/site/default/images/tags/default.png'" /></td>
					<td>
						<a href="{@url:tag/index/view?name=$v['tag_name']|pw}" target="_blank" class="J_tag_name">{$v['tag_name']}</a>
						<p>{@pw::substrs($v['excerpt'],30);}</p>
					</td>
					<td>{$v['content_count']}/<span>{$v['attention_count']}</span></td>
					<td>{$v['categories']}</td>
					<td><!--# echo implode(',', $realtedTopicsHtml); #--></td>
					<td><!--# if ($v['ifhot']){ #-->是<!--# }else{ #-->否<!--# } #--></td>
					<td><a href="{@url:tag/manage/edit?id=$v['tag_id']}" title="编辑话题" class="mr5 J_dialog">[编辑]</a><a href="{@url:tag/index/view?name=$v['tag_name']|pw}" target="_blank">[内容管理]</a></td>
				</tr>
				<!--# } #-->
				</tbody>
			</table>
			<div class="p10">
				<page tpl='TPL:common.page' page='$page' count='$count' per='$perPage' url='/tag/manage/run' args='$args'/>
			</div>
		</div>
		
		<div class="btn_wrap">
			<div class="btn_wrap_pd" id="J_sub_wrap">
				<label class="mr10"><input class="J_check_all" data-checklist="J_check_y" data-direction="y" type="checkbox">全选</label>
				<button class="btn J_ajax_submit_btn" data-subcheck="true" data-action="{@url:/tag/manage/sethot}" type="submit">设为热门</button>
				<button class="btn J_ajax_submit_btn" data-subcheck="true" data-action="{@url:/tag/manage/deletehot}" type="submit">取消热门</button>
				<button class="btn" id="J_merger_btn" type="submit" style="width:140px;">合并到关联话题</button>
				<button class="btn" id="J_move_btn" type="submit">移动分类</button>
				<button class="btn J_ajax_submit_btn" data-subcheck="true" data-msg="确定要删除吗？" data-action="{@url:/tag/manage/delete}" type="submit">删除</button>
			</div>
		</div>
	</form>
	<!--# } else { #-->
	<div class="not_content_mini"><i></i>啊哦，没有符合条件的内容！</div>
	<!--# } #-->
</div>
<template source='TPL:admin.common.footer' />
<script>
Wind.use('dialog', 'ajaxForm', function(){
	var URL_MERGE = "{@url:/tag/manage/merge}",	//合并
		URL_MOVE = "{@url:/tag/manage/move}";		//移动
	
	//点击合并
	$('#J_merger_btn').on('click', function(e){
		e.preventDefault();
		tagManPop($(this), 'merger');
		
	});
	
	//点击移动
	$('#J_move_btn').on('click', function(e){
		e.preventDefault();
		tagManPop($(this), 'move');
	});

	function tagManPop(btn, type) {
		var url = (type == 'merger' ? URL_MERGE : URL_MOVE),
			title = (type == 'merger' ? '合并到关联话题' : '移动分类');
		btn.parent().find('span').remove();
		if(getCheckedTr()) {
			Wind.dialog.open( url ,{
				onClose : function() {
					btn.focus();
				},
				title: title
			});

		}else{
			$( '<span class="tips_error">请至少选择一项</span>' ).appendTo(btn.parent()).fadeIn( 'fast' );
		}

	}
	
	//选择统计
	function getCheckedTr(){
		if($('#J_tag_list input.J_check:checked').length >= 1) {
			return true;
		}else{
			return false;
		}
	}

});
</script>
</body>
</html>
